package com.youyi.yychosesdk.models.album;

import android.content.Context;
import android.support.v4.content.PermissionChecker;

import com.lkx.liandianqinew.R;
import com.yanzhenjie.permission.runtime.Permission;
import com.youyi.yychosesdk.models.album.entity.Album;
import com.youyi.yychosesdk.models.album.entity.AlbumItem;
import com.youyi.yychosesdk.models.album.entity.Photo;
import com.youyi.yychosesdk.setting.Setting;
import java.util.ArrayList;

public class AlbumModel {
    private static final String TAG = "AlbumModel";
    public static AlbumModel instance;
    public Album album = new Album();
    public volatile boolean canRun = true;
    private String[] projections;

    public interface CallBack {
        void onAlbumWorkedCallBack();
    }

    private AlbumModel() {
    }

    public static AlbumModel getInstance() {
        if (instance == null) {
            synchronized (AlbumModel.class) {
                if (instance == null) {
                    instance = new AlbumModel();
                }
            }
        }
        return instance;
    }

    public void query(Context context, final CallBack callBack) {
        final Context applicationContext = context.getApplicationContext();
        if (PermissionChecker.checkSelfPermission(context, Permission.READ_EXTERNAL_STORAGE) == 0) {
            this.canRun = true;
            new Thread(new Runnable() {
                /* class com.youyi.yychosesdk.models.album.AlbumModel.AnonymousClass1 */

                public void run() {
                    AlbumModel.this.initAlbum(applicationContext);
                    if (callBack != null) {
                        callBack.onAlbumWorkedCallBack();
                    }
                }
            }).start();
        } else if (callBack != null) {
            callBack.onAlbumWorkedCallBack();
        }
    }

    public void stopQuery() {
        this.canRun = false;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:106:0x024c  */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x0253  */
    /* JADX WARNING: Removed duplicated region for block: B:110:0x0268  */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x0269  */
    /* JADX WARNING: Removed duplicated region for block: B:138:0x0315  */
    /* JADX WARNING: Removed duplicated region for block: B:163:0x0324 A[EDGE_INSN: B:163:0x0324->B:142:0x0324 ?: BREAK  , SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x00b2  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x00bb  */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x00d8  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00f1  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00f3  */
    /* JADX WARNING: Removed duplicated region for block: B:92:0x0219  */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x022a  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private synchronized void initAlbum(Context r35) {
        /*
        // Method dump skipped, instructions count: 931
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yychosesdk.models.album.AlbumModel.initAlbum(android.content.Context):void");
    }

    public String getAllAlbumName(Context context) {
        String string = context.getString(R.string.selector_folder_all_video_photo_easy_photos);
        if (Setting.isOnlyVideo()) {
            return context.getString(R.string.selector_folder_video_easy_photos);
        }
        return !Setting.showVideo ? context.getString(R.string.selector_folder_all_easy_photos) : string;
    }

    public ArrayList<Photo> getCurrAlbumItemPhotos(int i) {
        return this.album.getAlbumItem(i).photos;
    }

    public ArrayList<AlbumItem> getAlbumItems() {
        return this.album.albumItems;
    }

    public String[] getProjections() {
        String[] strArr = this.projections;
        if (strArr == null || strArr.length == 0) {
            if (Setting.useWidth) {
                this.projections = new String[]{"_id", "_data", "_display_name", "date_modified", "mime_type", "_size", "bucket_display_name", "width", "height", "orientation"};
            } else {
                this.projections = new String[]{"_id", "_data", "_display_name", "date_modified", "mime_type", "_size", "bucket_display_name"};
            }
        }
        return this.projections;
    }
}
